﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player_Controller : MonoBehaviour
{
    private float h, v;
    public float speed = 3;
    public float rotateSpeed = 90;
    public GameObject prefab;
    private Transform firePoint;

    void Start()
    {
        firePoint = transform.Find("Fire_Point");
    }

    void Update()
    {
        //实现角色移动
        h = Input.GetAxisRaw("Horizontal");
        v = Input.GetAxisRaw("Vertical");
        transform.Translate(Vector3.forward * speed * Time.deltaTime * v);
        transform.Rotate(Vector3.up * rotateSpeed * Time.deltaTime * h);
        //按下空格键创建子弹，并将子弹放在开火点
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Instantiate(prefab, firePoint.position, transform.rotation);
        }
    }
}
